{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<table class="table-class">
	<thead>
		<tr align="center">
			<th ><i class="checkbox-common"><input type="checkbox" onclick="CheckAll(this)"></i></th>
			<th>会员</th>
			<th>订单ID</th>
			<th>投诉及回复</th>
			<th>状态</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>

<!-- 回复用户投诉 -->
<div class="modal fade hide" id="apply_complain" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

	<div class="modal-dialog">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
				<h4 class="modal-title" id="myModalLabel">回复用户投诉</h4>
			</div>
			<div class="modal-body">
				<div class="modal-infp-style">
					<table class="modal-tab">
						<tr>
							<td style="width:20%">原因</td>
							<td colspan='3'>
								<textarea id="replay" class="textarea-common" style="width: 400px!important;height: 200px"></textarea>
							</td>
						</tr>
					</table>
				</div>
			</div>

			<div class="modal-footer">
				<input type="hidden" id="apply_complain_cid" />
				<button class="btn btn-primary" onclick="act_apply_complain()">保存</button>
				<button class="btn" data-dismiss="modal">关闭</button>
			</div>
		</div>
	</div>

</div>
{/block}
{block name="script"}

<script type="text/javascript">
function LoadingInfo(page_index) {
	var search_text = $("#search_text").val();
	$.ajax({
		type : "post",
		url : document.location,
		data : { "page_index" : page_index, "page_size" :  $("#showNumber").val() },
		success : function(data) {
			if (data["data"].length > 0) {
				$(".table-class tbody").empty();
				for (var i = 0; i < data["data"].length; i++) {
					var html = '';
					html += '<tr align="center">';
					html += '<td><i class="checkbox-common"><input name="sub" type="checkbox" value="'+ data["data"][i]["run_mill_id"]+'" ></i></td>';
                    html += '<td>'+ data["data"][i]["real_name"]+'<br>'+ data["data"][i]["user_tel"]+'</td>';
                    html += '<td>'+ data["data"][i]["tid"]+'</td>';
                    html += '<td align="left">';
                    html += '申诉时间：'+ timeStampTurnTime(data["data"][i]["create_time"])+'<br>';
                    html += '申诉内容：'+ data["data"][i]["remark"]+'<br>';
					html += '申诉凭证：<img src="'+ data["data"][i]["sell_complain"]+'" ><br>';
                    html += '回复时间：'+ timeStampTurnTime(data["data"][i]["replay_time"])+'<br>';
                    html += '回复内容：'+ data["data"][i]["replay"]+'<br>';
                    html += '</td>';
                    html += '<td>'+ data["data"][i]["status"]+'</td>';
                    html += '<td>';
                    html += '<a onclick="apply_complain('+ data["data"][i]["cid"]+')">回复</a><br/>';
                    html += '<a onclick="delete_record('+ data["data"][i]["cid"]+')">删除</a>';
                    html += '</td>';
					html += '</tr>';
					$(".table-class tbody").append(html);
				}
			} else {
				var html = '<tr align="center"><td colspan="8">暂无符合条件的数据记录</td></tr>';
				$(".table-class tbody").html(html);
			}
			initPageData(data["page_count"],data['data'].length,data['total_count']);
			$("#pageNumber").html(pagenumShow(jumpNumber,$("#page_count").val(),{$pageshow}));
		}
	});
}

// 全选
function CheckAll(event){
	var checked = event.checked;
	$("#productTbody input[type = 'checkbox']").prop("checked",checked);
	if(checked) $(".table-class tbody input[type = 'checkbox']").parent().addClass("selected");
	else $(".table-class tbody input[type = 'checkbox']").parent().removeClass("selected");
}

// 删除记录
function delete_record(id){
    $( "#dialog" ).dialog({
        buttons: {
            "确定": function() {
                $.ajax({
                    type : "post",
                    url : "{:__URL('ADMIN_MAIN/Mine/tradeComplainDel')}",
                    data : { "id" : id },
                    dataType : "json",
                    success : function(data) {
                        if(data["code"] > 0 ){
                            LoadingInfo(1);
                            showTip(data["message"],'success');
                            $("#chek_all").prop("checked", false);
                        }else{
                            showTip(data["message"],'error');
                        }
                    }
                });
                $(this).dialog('close');
            },
            "取消,#e57373": function() {
                $(this).dialog('close');
            },
        },
        contentText:"确定要删除吗？",
    });
}

// 投诉回复弹出
function apply_complain(cid){
    $("#apply_complain").modal("show");
    $("#apply_complain_cid").val(cid);
}

// 投诉回复确认
function act_apply_complain() {
    var cid = $("#apply_complain_cid").val();
    var replay = $("#replay").val();
    $.ajax({
        type : "post",
        url : "{:__URL('ADMIN_MAIN/mine/apply_complain')}",
        data : { "cid" : cid, "replay" : replay },
        success : function(data) {
            if (data["code"] > 0) {
                LoadingInfo(getCurrentIndex(cid,'#productTbody'));
                showTip(data['message'],'success');
                $("#apply_complain").modal("hide");
                $("#replay").val('');
            }else{
                showTip(data['message'],'error');
            }
        }
    });
}
</script>
{/block}